﻿namespace Agile.Service.Admin.Model;

public partial class SysDepartmentModel
{
    protected override async Task<string> ToLogAsync(BaseModel newBaseModel, BaseModel oldBaseModel, IServiceProvider serviceProvider)
    {
        var newModel = (SysDepartmentModel)newBaseModel;
        var oldModel = (SysDepartmentModel)oldBaseModel;

        var logBuilder = new LogContentBuilder();
        if (newModel.IsChanged(nameof(DepartmentName)))
        {
            logBuilder.Append("部门名称".ToLog(oldModel.DepartmentName, newModel.DepartmentName));
        }
        if (newModel.IsChanged(nameof(Enabled)))
        {
            logBuilder.Append("是否启用".ToLog(oldModel.Enabled ? "启用" : "禁用", newModel.Enabled ? "启用" : "禁用"));
        } 
        if (newModel.IsChanged(nameof(Remark)))
        {
            logBuilder.Append("备注".ToLog(oldModel.Remark, newModel.Remark));
        }
        await Task.CompletedTask;
        return logBuilder.ToString();
    }
}
